package cn.belong.jk.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.belong.jk.entity.Contract;
import cn.belong.jk.entity.Export;
import cn.belong.jk.service.ExportService;

@Controller  
@RequestMapping("export")
public class ExportController extends BaseController {

    @Autowired  
    ExportService exportService;  
      
    @RequestMapping("/list.action")  
    public String list(Model model){  
        List<Export> dataList=exportService.find(null);  
        model.addAttribute("dataList", dataList);  
          
        return "/cargo/export/jExportList.jsp";  
    }  
    
  //购销合同列表  
    @RequestMapping("/contractList.action")  
    public String contractList(Model model){  
        List<Contract> dataList=exportService.getContractList();  
        model.addAttribute("dataList", dataList);  
          
        return "/cargo/export/jContractList.jsp";//报运目录下调用购销合同列表  
    }  
    
  //报运新增，直接在后台进行保存  
    @RequestMapping("/insert.action")  
    public String insert(String [] id){  
        exportService.insert(id);  
          
        return "redirect:/export/list.action";  
    }  
    

    
  //转向修改界面  
    @RequestMapping("/toupdate.action")  
    public String toupdate(String id,Model model){  
        Export obj=exportService.get(id);  
        model.addAttribute("obj", obj);  
          
        //准备批量修改控件的数据mrecord  
        model.addAttribute("mRecordData",exportService.getMrecordData(id));  
          
        return "/cargo/export/jExportUpdate.jsp";  
    }  
      
	@RequestMapping("/update.action")
	public String update(Export export,
				String[] mr_id,
				Integer[] mr_orderNo,
				Integer[] mr_cnumber,
				Double[] mr_grossWeight,
				Double[] mr_netWeight,
				Double[] mr_sizeLength,
				Double[] mr_sizeWidth,
				Double[] mr_sizeHeight,
				Double[] mr_exPrice,
				Double[] mr_tax,
				Integer[] mr_changed
			){
		exportService.update(export,
				mr_id,
				mr_orderNo,
				mr_cnumber,
				mr_grossWeight,
				mr_netWeight,
				mr_sizeLength,
				mr_sizeWidth,
				mr_sizeHeight,
				mr_exPrice,
				mr_tax,
				mr_changed
			);
		
		return "redirect:/export/list.action";
	}
}
